#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask import Flask,jsonify
from models import GameInfo
import json

app = Flask(__name__)

@app.route('/')
def index():
    return "Hello, World!"

@app.route('/gamestore/api/gameinfo',methods=['GET'])
def get_gameInfo():
    gameInfos = GameInfo.find_all()
    # print json.dumps(gameInfos,ensure_ascii=False)
    # return json.dumps({'gameInfos':gameInfos},ensure_ascii=False) 
    return json.dumps(gameInfos,ensure_ascii=False) 


@app.route('/gamestore/api/gameinfo/<int:game_id>',methods=['GET'])
def get_gameInfo_by_id(game_id):
    if game_id is not None:
        gameInfoOne = GameInfo.get(game_id)
        # print json.dumps(gameInfos,ensure_ascii=False)
        return json.dumps({'oneGame':gameInfoOne},ensure_ascii=False) 

if __name__ == '__main__':
    app.run(debug=True)
